package com.example.rabbitmq.example.springboot;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class RabbitConfig {

    @Bean
    public Queue myQueue(){
        Map<String, Object> props = new HashMap<>();
        props.put("x-message-ttl", 10000);
        return new Queue("myQueue", false,false, false, props);
    }

    @Bean
    public Exchange exchange(){
        Map<String, Object> props = new HashMap<>();
        props.put("x-delayed-type", ExchangeTypes.FANOUT);
        Exchange exchange = new CustomExchange("myex", "x-delayed-message", true, false, props);
        return exchange;
    }

    @Bean
    public Binding binding(){
        return new Binding("myQueue",Binding.DestinationType.QUEUE, "myex", "direct.ex", null);
    }
}
